package com.hikealoha.hikealoha;

import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

import java.util.Scanner;


public class MapActivity extends ActionBarActivity {

    static final LatLng HONOLULU = new LatLng(21.3000, 157.8167);
    private GoogleMap map;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Scanner scanner;
        double lat = 0.0;
        double lon = 0.0;
        // I'm commenting out stuff just to "reset to defaults"
        Intent intent = getIntent();
        String value = intent.getStringExtra("dummy");

        //assuming String value is split between "18.3,24.0", just need to split on comma
        //scanner = new Scanner(value)
        //String[] splitter = value.split(",");
        //lat = Float.parseFloat(splitter[0]);
        //lon = Float.parseFloat(splitter[1]);

        //there will be intents received; either addresses or raw coordinates of
        //hiking locations.
        //figure out how to integrate all of this into the google maps

        //when receiving intents from the previous activity, this will be attached to
        // the variable where I zoom in on the given hiking location

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map);

        map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
                .getMap();

        Marker honolulu = map.addMarker(new MarkerOptions().position(HONOLULU)
                .title("Honolulu, HI"));

        map.moveCamera(CameraUpdateFactory.newLatLngZoom(HONOLULU, 15));

        map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_map, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
